package com.nsoft.thickclient.trackMove.party;

import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

import com.nsoft.server.serviceImpl.FacadeFactoryImpl;
import com.nsoft.thickclient.controller.ApplicationController;
import com.nsoft.thickclient.trackMove.intr.party.Party;
import com.nsoft.thickclient.trackMove.search.SearchAction;
import com.nsoft.thickclient.trackMove.search.SearchView;
import com.nsoft.thickclient.trackMove.search.SearchViewController;

public class SearchPartyAction implements SearchAction<Party> {

	public void delete(Party bean) {
		// TODO Auto-generated method stub

	}

	public void edit(Party bean, ApplicationController applicationController) {
		PartyViewController controller = new PartyViewController(true);
		applicationController.openScreen(controller, new Dimension(800, 550));
		controller.getPartyView().setWorkingBean(bean);
	}

	public Party getNewBean() {
		return new Party();
	}

	public SearchView<Party> getView(SearchViewController<Party> controller) {
		List<Party> list = new ArrayList<Party>();
		for (int i = 0; i < 10; i++) {
			Party party = new Party();
			party.setName("name -> " + i);
			party.setHomePhone("homePhone -> " + i);
			list.add(party);
		}

		PartyView partyView = new PartyView(new Party());
		String[] properties = { "name", "homePhone", "pan" };
		String[] headers = { "Name", "Address", "Pan number" };
		SearchView<Party> searchView = new SearchView<Party>(list, properties,
				headers, partyView, controller);
		return searchView;
	}

	public List<Party> search(Party bean) {
		return FacadeFactoryImpl.getPartyService().searchParties(bean);
		 //new ArrayList<Party>();
	}

}
